package com.java.demo.concurrent;

import java.util.concurrent.LinkedBlockingQueue;

public class LinkedBlockingQueueDemo {
    public static void main(String[] args) throws InterruptedException {
        LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<Integer>(10);
        queue.add(10);  // 队列满时，会抛异常
        queue.put(100);  // 队列满时，会阻塞
        Boolean success = queue.offer(20);  // 队列满时，会返回 false
        System.out.println(queue.poll());  // 队列为空时，会返回 null
        System.out.println(queue.take());  // 队列为空时，会阻塞

    }
}
